// 实现后序遍历 左右根；换成入栈顺序应该是根右左；出栈之后再将数组反转

var postorderTraversal = function (root) {
    if (!root) return []

    const res = []
    const stack = []
    stack.push(root)

    while (stack.length) {
        const cur = stack.pop()
        res.unshift(cur.val)//

        if (cur.left) {
            stack.push(cur.left)
        }
        if (cur.right) {
            sgtack.push(cur.right)

        }
    }
    return res
}